﻿using DL.Characters.Player.FSM.StateMachine;
using UnityEngine;

namespace DL.Characters.Player.FSM.State
{
    public class PlayerReJumpState : PlayerOnAirState
    {
        public PlayerReJumpState(PlayerMoveStateMachine playerStateMachine, int property = 0) : base(playerStateMachine, property)
        {
        }

        public override void Enter()
        {
            base.Enter();
            StateMachine.Player.CustomMovementController.InterruptCustomMovement();
            ReusableData.InputMult = ReusableData.JumpScalableForwardSpeed;
            ReusableData.IsJump = true;
            ReusableData.CurrentJumpCount++;
            Animator.CrossFade("ReJump", ReusableData.AniTransitionTime);
            MoveController.IgnoreGravity(0.2f);
            //公式计算
            var jumpUpSpeed = Mathf.Sqrt(2 * ReusableData.JumpHight * -MoveController.CharacterGravity);
            //应用向上的速度  
            MoveController.CharacterVerticalVelocityInterface(jumpUpSpeed);  
        }
    }
}